home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / c-tools / c_examples / appwindow / appwindow.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-18  |  1.7 KB  |  69 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. // AppWindow.cpp
  3. //
  4. // Deryk Robosson
  5. // May 9, 1996
  6. //////////////////////////////////////////////////////////////////////////////
  7.  
  8. //////////////////////////////////////////////////////////////////////////////
  9. // INCLUDES
  10. #include "aframe:include/AppWindow.hpp"
  11.  
  12. //////////////////////////////////////////////////////////////////////////////
  13. //
  14.  
  15. AFAppWindow::AFAppWindow()
  16.     :WorkbenchBase(NULL),
  17.     IconBase(NULL),
  18.     aw(NULL)
  19. {
  20.     if(!WorkbenchBase) {
  21.         if(!(WorkbenchBase=(struct WorkbenchBase*)OpenLibrary((UBYTE*)"workbench.library",(ULONG)36)))
  22.             printf("failed to open workbench.library\n");
  23.     }
  24.  
  25.     if(!IconBase) {
  26.         if(!(IconBase=(struct IconBase*)OpenLibrary((UBYTE*)"icon.library",(ULONG)36)))
  27.             printf("failed to open icon.library\n");
  28.     }
  29. }
  30.  
  31. AFAppWindow::~AFAppWindow()
  32. {
  33.     if(aw) {
  34.         RemoveAppWindow(aw);
  35.         aw=NULL;
  36.     }
  37.  
  38.     if(WorkbenchBase) {
  39.         CloseLibrary((struct Library*)WorkbenchBase);
  40.         WorkbenchBase=NULL;
  41.     }
  42.     if(IconBase) {
  43.         CloseLibrary((struct Library*)IconBase);
  44.         IconBase=NULL;
  45.     }
  46. }
  47.  
  48. void AFAppWindow::Create(AFAmigaApp *theapp, AFRect *rect, ULONG id, LPMsgPort appmsgport)
  49. {
  50.     AFWindow::Create(theapp, rect);
  51.  
  52.     if(!(aw = (struct AppWindow*)AddAppWindow((ULONG)id, (ULONG)0, m_pWindow, appmsgport, NULL)))
  53.         printf("AppWindow Failed!\n");
  54. }
  55.  
  56. void AFAppWindow::Create(AFAmigaApp *theapp, AFRect *rect, ULONG id)
  57. {
  58.     Create(theapp, rect, id, theapp->appmsgport);
  59. }
  60.  
  61. void AFAppWindow::OnCloseWindow(LPIntuiMessage imess)
  62. {
  63.     if(aw) {
  64.         RemoveAppWindow(aw);
  65.         aw=NULL;
  66.     }
  67.     AFWindow::DestroyWindow();
  68. }
  69.